package com.woniuxy.usersecurity.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/operate")
public class SecUserRoleController {
    @GetMapping("/allot")
    public String allotOrder() {
        Object object = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if ("anonymousUser".equals(object)){
            System.out.println("anonymousUser 用户不存在"+object);
        }else {
            System.out.println("用户存在"+object);
        }
        return (String) object;
    }
}






